#ifndef ELECTRONICSCALERECORDER_H
#define ELECTRONICSCALERECORDER_H

#include <QObject>
#include <QTimer>
#include "excelengine.h"
#include "moduleelectronicscaledefine.h"

class ElectronicScaleRecorder : public QObject
{
    Q_OBJECT
public:
    explicit ElectronicScaleRecorder(QObject *parent = nullptr);
    ~ElectronicScaleRecorder();

    void setFileName(const QString &str);
    QString getFileName() const;

    void setPeriod(quint32 second);
    quint32 getPeriod() const;

    bool isRecording() const;

    bool start();
    bool stop();

    bool saveOneRecord(electronicscale::Sample sample);

signals:

public slots:
    void onTimeout();

private:
    ExcelEngine                             *m_excelEngine = nullptr;

    QString                                 m_fileName;
    quint32                                 m_period = 30 * 60; // s
    quint32                                 m_periodCnt;
    QTimer                                  *m_timer = nullptr;

    bool                                    m_isRecording = false;
};

#endif // ELECTRONICSCALERECORDER_H
